package com.peycard.vista;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.peycard.common.PortalUserDTO;
import com.peycard.util.Constantes;

@Controller(Constantes.BEAN_MENU)
@Scope(Constantes.SCOPE_SESSION)
public class MenuControlador extends BaseController implements Serializable {
	private static final long serialVersionUID = 1L;
	private static final Logger LOGGER = LoggerFactory
			.getLogger(MenuControlador.class);
	private String userName;
	private String fullUserName;

	private void initUserName() {
		if (userName == null || userName.length() == 0) {
			Authentication auth = SecurityContextHolder.getContext()
					.getAuthentication();
			userName = auth.getName(); // get logged in username
			LOGGER.info(userName.toString());
		}
	}

	public String goToPortalUserPage() {
		return "goToPortalUserPage";
	}

	public String goToMobileUserPage() {
		return "goToMobileUserPage";
	}

	public String goToCompanyPage() {
		return "goToCompanyPage";
	}

	public String goToTransactionPage() {
		return "goToTransactionPage";
	}

	public String goToReaderPage() {
		return "goToReaderPage";
	}

	private void initFullUserName() {
		initUserName();
		fullUserName = userName;
	}

	/**
	 * @return the userName
	 */
	public String getUserName() {
		initUserName();
		return userName;
	}

	/**
	 * @param userName
	 *            the userName to set
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	/**
	 * @return the fullUserName
	 */
	public String getFullUserName() {
		initFullUserName();
		return fullUserName;
	}

	/**
	 * @param fullUserName
	 *            the fullUserName to set
	 */
	public void setFullUserName(String fullUserName) {
		this.fullUserName = fullUserName;
	}
}